/*
#####################################################################
####################	   T R I B U I T 		#####################
#####################################################################

Copyright (C) 2010  Christoph Schnack, Berlin (Germany)

This file is part of Tribuit.

    Tribuit is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Tribuit is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Tribuit.  If not, see <http://www.gnu.org/licenses/>.


########################################################################
*/
package GuiTools;

import java.awt.Color;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 * 
 * Creates a JPanel containing a JLabel
 * 
 * @author Christoph Schnack
 *
 */

public class Header extends JPanel{
	int insetsSize = 15;
	Insets insets = new Insets(insetsSize,insetsSize,insetsSize,insetsSize),lowerInsets = new Insets(5,insetsSize,insetsSize,insetsSize);
	Font font = new Font(Font.SERIF,Font.BOLD,30);
	Color bgColor = GuiTools.BGCOLOR;
	Color fontColor = Color.white;
	String text,subText;
	JLabel label;
	/**
	 * Creates a fully customized Header
	 * 
	 * @param txt text for the JPanel
	 * @param fontCol font color
	 * @param bgCol background color
	 * @param ins insets from all sides
	 * @param f Font of the JPanel
	 */
	public Header(String txt,Color fontCol,Color bgCol,int ins,Font f){
		super();
		text = txt;
		fontColor = fontCol;
		insetsSize = ins;
		new Insets(insetsSize,insetsSize,insetsSize,insetsSize);
		font = f;
		bgColor = bgCol;
		build();
	}
	
	public Header(String txt,String subTitle){
		super();
		text = txt;
		subText = subTitle;
		build();
	}
	
	public Header(String txt,Insets ins){
		super();
		insets = ins;
		text = txt;
		build();
	}
	
	public Header(String txt){
		super();
		text = txt;
		build();
	}
		
	public void build(){
		label = new JLabel(text);
		label.setForeground(fontColor);
		label.setFont(font);
		this.setLayout(new GridBagLayout());
		GridBagConstraints gbc = new GridBagConstraints();
		gbc.insets = insets;
		this.add(label,gbc);
		if(subText!=null){
			gbc.gridy=1;
			gbc.insets = lowerInsets;
			this.add(new JLabel(subText),gbc);
		}
		this.setBackground(bgColor);
		
	}
	
	public void setText(String txt){
		label.setText(txt);
	}
	
	
}